const jwt = require("jsonwebtoken");

function filter(req, res, next) {
    if (req.path == "/users/login") {
        next();
    } else {
        let authorization = req.body.authorization || req.headers.authorization || req.query.authorization;
        let secrect = "How_are_you";
        jwt.verify(authorization, secrect, function (err, decode) {
            if (err) {
                res.send({ state: false, status: 0, msg: "校验失败" })
            } else {
                console.log("token验证中");
                console.log(555, decode);
                next();
            }
        })

    }
}
module.exports = filter;